<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
      div {
        width: 100px;
        height: 100px;
        background-color: pink;
      }
      .change {
        background-color: purple;
        color: #fff;
        font-size: 25px;
        margin-top: 100px;
      }
    </style>
  </head>
  <body>
    <div class="first">文本</div>
    <script>
      var test = document.querySelector('div');
      test.onclick = function () {
        this.className = 'change';
        // this.className = 'first change';
      };
    </script>
  </body>
</html>